#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QLabel>
#include <QLayout>
#include <QPushButton>
#include <QLineEdit>
#include <QTextBrowser>

#include <windows.h>

#include "imgwidget.h"
#include "uinterface.h"
#include "threadmanager.h"

namespace port_param{
const int inputBufferSize = 154400;
const int outputBufferSize = 154400;
}

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = 0);
    ~Widget();
public slots:
    void btnOpen_clicked();
    void btnClose_clicked();
    void btnSend_clicked();
private:
    /* Frame */
    QGridLayout* wholeFrame;
    QHBoxLayout* imageFrame;
    QVBoxLayout* inputFrame;
    QHBoxLayout* portFrame;
    QHBoxLayout* btnFrame;
    QVBoxLayout* terminalFrame;

    /* Module */
    QLineEdit* portInput;
    QPushButton* btnOpenPort;
    QPushButton* btnClosePort;
    QLabel* portLabel;
    QTextBrowser* terminal;
    QPushButton* btnSendData;
    QLineEdit* emmityInput;

    /* Data */
    HANDLE portHandle;

    /* Thread */
    ThreadManager* manager;

    IMGWIDGET* imageIr;

signals:
    void ready2read();
    void stop2read();
    void ready2write();
};

#endif // WIDGET_H
